package com.sc.test.mytest;

import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.sc.test.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * description:
 * author: ShenChao
 * time: 2019-04-07
 * update:
 */
public class CardActivity extends AppCompatActivity {
    @BindView(R.id.image)
    ImageView image;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_card);
        ButterKnife.bind(this);

//        image.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
//            @Override
//            public void onGlobalLayout() {
//                System.out.println(image.getWidth() + "---old---" + image.getHeight());
//                ViewGroup.LayoutParams params = image.getLayoutParams();
//                params.height = (int) (image.getWidth() / 1.55);
//                image.setLayoutParams(params);
//                System.out.println(image.getWidth() + "---new---" + image.getHeight());
//            }
//        });

        ViewGroup.LayoutParams params = image.getLayoutParams();
        params.height = (int) (image.getWidth() / 1.55);
        image.setLayoutParams(params);
    }


}
